import type { AddressParams } from '@/types/address'
import type { AddressItem } from '@/types/global'
import { http } from '@/utils/http'

// 获取所有地址
export const getAllAddress = () => {
  return http<AddressItem[]>({
    url: '/member/address',
    method: 'GET',
  })
}

// 新增地址
export const addAddress = (data: AddressParams) => {
  return http({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

// 根据ID获取地址详情
export const getAddressById = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'GET',
  })
}

// 修改地址
export const putAddressById = (id: string, data: AddressParams) => {
  return http({
    url: '/member/address/' + id,
    method: 'PUT',
    data,
  })
}

// 删除地址
export const deleteAddressById = (id: string) => {
  return http({
    url: '/member/address/' + id,
    method: 'DELETE',
  })
}
